# models.py
import django_tables2 as tables
from django_tables2.utils import A
from django.core.urlresolvers import reverse
from django_moneyguard import models
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe

TEMPLATE_LINK = '{%% load i18n %%}<a href="{%% url \'%(url_name)s\' record.pk %%}">{%% trans \'%(link_text)s\' %%}</a>'

class AccountTable(tables.Table):
    
   # editLink = tables.URLColumn('django_moneyguard:account_update', args=[A('id')], orderable=False,)
    #edit_link = tables.TemplateColumn(TEMPLATE_LINK % {'url_name':'django_moneyguard:account_edit', 'link_text':'Edit', }, verbose_name='Edit')
    #delete_link = tables.TemplateColumn(TEMPLATE_LINK % {'url_name':'django_moneyguard:account_delete', 'link_text':'delete', }, verbose_name='delete')
   
    edit_link = tables.TemplateColumn(template_name='django_moneyguard/columns/link_update_column.html', verbose_name='update', orderable=False)
    delete_link = tables.TemplateColumn(template_name='django_moneyguard/columns/link_delete_column.html', verbose_name='delete', orderable=False)
    class Meta:
        model = models.Account
        attrs = {"class": "paleblue"}
        fields = ('name', 'active', 'edit_link', 'delete_link')
        sequence = ('active','name', 'edit_link', 'delete_link')

class CreditCardTable(tables.Table):
    
   # editLink = tables.URLColumn('django_moneyguard:account_update', args=[A('id')], orderable=False,)
    #edit_link = tables.TemplateColumn(TEMPLATE_LINK % {'url_name':'django_moneyguard:account_edit', 'link_text':'Edit', }, verbose_name='Edit')
    #delete_link = tables.TemplateColumn(TEMPLATE_LINK % {'url_name':'django_moneyguard:account_delete', 'link_text':'delete', }, verbose_name='delete')
   
    edit_link = tables.TemplateColumn(template_name='django_moneyguard/columns/link_update_column.html', verbose_name='update', orderable=False)
    delete_link = tables.TemplateColumn(template_name='django_moneyguard/columns/link_delete_column.html', verbose_name='delete', orderable=False)
    class Meta:
        model = models.CreditCard
        attrs = {"class": "paleblue"}
        fields = ('name', 'active', 'edit_link', 'delete_link')
        sequence = ('active','name', 'edit_link', 'delete_link')
